/******************************************************
* drv_l2_touch_panel.c
*
* Purpose: Touch panel layer 2 driver
*
* Author: Eugene Hsu
*
* Date: 2017/03/29
*
* Copyright Generalplus Corp. ALL RIGHTS RESERVED.
*
* Version :
* History :
*
*******************************************************/
#include "project.h"
#include "driver_l1.h"
#include "drv_l1_sfr.h"
#include "drv_l1_gpio.h"
#include "drv_l1_uart.h"
#include "drv_l2_touch_panel.h"
#include "board_config.h"

#if defined(TOUCH_PANEL_DEV) && TOUCH_PANEL_DEV == TOUCH_PANEL_DEV_GT911
extern TOUCH_PANEL_OPERATION_TBL_T	tp_911_op_tbl[];
#endif

TOUCH_PANEL_OPERATION_TBL_T *tp_op_tbl = NULL;

void drv_l2_tp_register_operation_table(TOUCH_PANEL_OPERATION_TBL_T *op_tbl)
{
	tp_op_tbl = op_tbl;
}

void drv_l2_touch_panel_init(void* cbk)
{
	/* Register touch panel operation table first */
	#if defined(TOUCH_PANEL_DEV) && TOUCH_PANEL_DEV == TOUCH_PANEL_DEV_GT911
	drv_l2_tp_register_operation_table(tp_911_op_tbl);
	#endif

	if(tp_op_tbl != NULL && tp_op_tbl->touch_panel_init != NULL)
		tp_op_tbl->touch_panel_init(cbk);
}

void drv_l2_touch_panel_uninit(void)
{
	if(tp_op_tbl != NULL && tp_op_tbl->touch_panel_uninit != NULL)
		tp_op_tbl->touch_panel_uninit();
}

void drv_l2_touch_panel_process_event(TOUCH_PANEL_KEY_INFO_S *key_info)
{
	if(tp_op_tbl != NULL && tp_op_tbl->touch_panel_process_event != NULL)
		tp_op_tbl->touch_panel_process_event(key_info);
}